#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int num_order(const void* e1, const void* e2)
{
	return *(int*)e1 - *(int*)e2;
}
void swap(char* bub1, char* bub2, size_t width)
{
	int i;
	for (i = 0; i < width; i++) {
		char tem = *bub1;
		*bub1 = *bub2;
		*bub2 = tem;
		*bub1++;
		*bub2++;
	}
}
void bubble_sort(void* base, int sz, int width, int (*num_order)(const void* e1, const void* e2))
{
	int i, j;
	for (i = 0; i < sz - 1; i++) {
		for (j = 0; j < sz - 1 - i; j++) {
			if (num_order((char*)base + j * width, (char*)base + (j + 1) * width) > 0) {
				swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
			}
		}
	}
}
void print(int arr[], int sz)
{
	int i;
	for (i = 0; i < sz; i++) {
		printf("%d ", arr[i]);
	}
}
int main()
{
	int arr[10] = { 9,5,7,3,1,4,6,2,8,0 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int width = sizeof(arr[0]);
	bubble_sort(arr, sz, width, num_order);
	print(arr, sz);
}